Skip to main content

All Questions

2votes
1answer
60views

Merge Sort with Minimum Sufficient Variables, Verbosity and better Space Complexity

The majority of merge sort implementations searched online are provided with unnecessary variables and code lines. Here is an attempt to reduce that. However, does passing back the subArray as return ...
Thomas Mathew's user avatar
6votes
5answers
3kviews

Sort an array of 0s, 1s and 2s in Java

Write a program to sort an array of 0's,1's and 2's in ascending order. Input: The first line contains an integer 'T' denoting the total number of test cases. In each test cases, First ...
Anirudh Thatipelli's user avatar
0votes
2answers
608views

Pancake sort inteview using java

Given an array of integers arr: Write a function flip(arr, k) that reverses the order of the first k elements in the array <...
Anirudh Thatipelli's user avatar
0votes
1answer
1kviews

Sort multidimensional array based of the difference in the value

Sort multidimensional array based of the difference in the value, if value is same sort on first column. Constrains: No of rows can be any but fixed no of column ie 2. Example: <...
Sandesh Wani's user avatar
5votes
1answer
6kviews

Sort a given string in ascending order

This code sort the string below in ascending order. I'd prefer it split-up in two or three smaller, simpler methods. I'm also wondering whether my algorithm has a decent time complexity. Given string ...
Adam's user avatar
  • 405
4votes
2answers
7kviews

Sorting a Stack in ascending order

Here's my implementation of sorting a stack in ascending order. The problem statement is as follows : Write a program to sort a stack in ascending order (with biggest items on top). You may use at ...
Mayur Kulkarni's user avatar
1vote
2answers
377views

Big O notation for quicksort implementation [closed]

I am trying to find out what would be the Big O notation of a quick sort implementation I wrote. If I can get some analysis on the code, that would be great. ...
nader's user avatar
1vote
4answers
383views

Finding the second largest element of large input sets

I have a problem where I need to find the second maximum element of the user inputs. It's an online practice problem and I can't figure out why the server responds back with a Non-Zero Exit Code error ...
arindrajit's user avatar
5votes
1answer
317views

Is this an efficient merge sort implementation with regards to average time complexity in Big-O notation?

Is my below merge sort implementation in O(n log n)? I am trying to implement a solution to find k-th largest element in a given integer list with duplicates with O(N*log(N)) average time complexity ...
user3157309's user avatar

close